package users

import (
	"api/internal/respons"
	"context"
	"user_srv/userclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type LightAchievementLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewLightAchievementLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LightAchievementLogic {
	return &LightAchievementLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *LightAchievementLogic) LightAchievement(req *types.LightAchievementRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	achievement, err := l.svcCtx.UserRpc.LightAchievement(l.ctx, &userclient.LightAchievementRequest{
		Id:              req.Id,
		AchievementName: req.AchievementName,
		IsLighted:       req.IsLighted,
		LightedTime:     req.LightedTime,
		Status:          req.Status,
	})
	if err != nil {
		return respons.Error(400, "服务端错误", err.Error()), err
	}
	return respons.Success(achievement), nil
}
